﻿/*
 * 版 本 v1.0
 * Copyright (c) 2013-2018 广州市同慧信息科技有限公司
 * 创建人：ftquan
 * 日 期：2017.03.22
 * 描 述：审计日志
 */
var selectedRow;
var refreshGirdData;
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.initGrid();
            page.bind();
        },
        bind: function () {
            // 搜索框初始化
            $('#keyword').on("keypress", function (e) {
                if (event.keyCode == "13") {
                    var $this = $(this);
                    var keyword = $this.val();
                    page.search({keyword: keyword});
                }
            });
            // 查询
            $('#btn_Search').on('click', function () {
                var keyword = $('#keyword').val();
                page.search({keyword: keyword});
            });
            // 刷新
            $('#lr_refresh').on('click', function () {
                location.reload();
            });
            // 同步旧系统附件
            $('#lr_sync').on('click', function () {
                $.ajax({
                    url: config.base_server() + 'syncFinancefiles/start?access_token=' + config.getToken().access_token,
                    type: "post",
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        if (result != null) {
                            learun.alert.info(result.resp_msg);
                        }
                    }
                });
            });

        },
        initGrid: function () {
            $('#gridtable').jfGrid({
                url: config.base_server() + 'logs/list?access_token=' + config.getToken().access_token,
                headData: [
                    {label: 'id', name: 'id', width: 80, align: 'left'},
                    {label: '模块', name: 'name', width: 180, align: 'left'},
                    {label: '操作用户', name: 'username', width: 80, align: 'left'},
                    {
                        label: "执行结果", name: "flag", width: 50, align: "center",
                        formatter: function (cellvalue) {
                            return cellvalue == 1 ? "成功" : "<span style='color: #f43838;'>失败</span>";
                            ;
                        }
                    },
                    {
                        label: "操作时间", name: "createTime", width: 140, align: "center",
                        formatter: function (value) {
                            return learun.formatDate(value, 'yyyy-MM-dd hh:mm:ss');
                        }
                    },
                    {label: "操作明细", name: "params", width: 550, align: "left"},
                    {label: "备注说明", name: "remark", width: 300, align: "left"}
                ],
                isPage: true,
                reloadSelected: true,
                mainId: 'id'
            });

            page.search();
        },
        search: function (param) {
            param = param || {};
            $('#gridtable').jfGridSet('reload', param);
        }
    };

    refreshGirdData = function () {
        page.search();
    };

    page.init();
}


